//
//  UserManagerViewController.m
//  SinceLe
//
//  Created by 李祎 on 15/11/13.
//  Copyright © 2015年 李元喜. All rights reserved.
//

#import "UserManagerViewController.h"
#import "CheckUserLogin.h"
#import "UserMessageTool.h"
#import "LoginViewController.h"

@interface UserManagerViewController ()

@property (strong, nonatomic) IBOutlet UIButton *headImageButton;
@property (strong, nonatomic) IBOutlet UILabel *nameLabel;

- (IBAction)headImageButtonClicked:(UIButton *)sender;

@end

@implementation UserManagerViewController


-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //更新UI
    [self updateUI];
}

#pragma mark --- 更新UI
-(void)updateUI{
    //头像
    //先判断是否登录
    if ([CheckUserLogin checkUserLogin]) {
        //已经登录
        //头像
        [_headImageButton setTitle:nil forState:UIControlStateNormal];
        [_headImageButton setBackgroundImage:[UIImage imageNamed:@"iconfont-touxiang"] forState:UIControlStateNormal];
        
        //昵称
        _nameLabel.text = [UserMessageTool getName];
        
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.navigationController.navigationBarHidden = YES;
    _headImageButton.layer.masksToBounds = YES;
    _headImageButton.layer.cornerRadius = CGRectGetWidth(_headImageButton.frame)*0.4;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)headImageButtonClicked:(UIButton *)sender {
    if (![CheckUserLogin checkUserLogin]) {
        LoginViewController* login = [[LoginViewController alloc] init];
        [self.navigationController pushViewController:login animated:YES];

    }
}
@end
